package com.jetgege.smartbox.Start;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.jetgege.smartbox.AddBox.AddDeviceActivity;
import com.jetgege.smartbox.Base.App;
import com.jetgege.smartbox.Base.BaseActivity;
import com.jetgege.smartbox.MainActivity;
import com.jetgege.smartbox.R;

/**
 * 启动页
 */
public class StartActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_start;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                checkFirstUse();
//                Intent intent=new Intent(StartActivity.this, MainActivity.class);
//                finish();
//                startActivity(intent);
            }
        },2000);
    }
    private void checkFirstUse(){
        boolean isFirstUse = App.preferences.getBoolean("isFirstUse",true);
        Intent intent=null;
        if(isFirstUse) {
            intent=new Intent(StartActivity.this, AddDeviceActivity.class);
            intent.setAction("StartActivity");
        }
        else   intent=new Intent(StartActivity.this, MainActivity.class);
        finish();
        startActivity(intent);
    }
}
